package com.ruoyi.service.impl;

import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.result.Result;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.mapper.CountMapper;
import com.ruoyi.mapper.T06Mapper;
import com.ruoyi.service.CountService;
import com.ruoyi.service.IT07Service;
import com.ruoyi.service.IT18Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class CountServiceImpl  implements CountService {

    @Autowired
    private IT07Service t07Service;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private IT18Service t18Service;
    @Autowired
    private CountMapper countMapper;
    @Override
    public Result dataAnly(Map<String, Object> map, HttpServletRequest request) {
        LoginUser loginUser = tokenService.getLoginUser(request);
        Long userId = loginUser.getUserId();
        Long comId = t18Service.selectF0301ByF1801(userId);
        map.put("F0301",comId);
        List<Map<String,Object>> list = countMapper.selectDataAnly(map);
        return Result.success(list,"查询成功");
    }

    @Override
    public Result userActiveAnalysis(Map<String, Object> map, HttpServletRequest request) {
        LoginUser loginUser = tokenService.getLoginUser(request);
        Long userId = loginUser.getUserId();
        Long comId = t18Service.selectF0301ByF1801(userId);
        map.put("F0301",comId);
        List<Map<String,Object>> list = countMapper.userActiveAnalysis(map);
        return Result.success(list, "查询成功");
    }

    @Override
    public Result depActiveAnalysis(Map<String, Object> map, HttpServletRequest request) {
        LoginUser loginUser = tokenService.getLoginUser(request);
        Long userId = loginUser.getUserId();
        Long comId = t18Service.selectF0301ByF1801(userId);
        map.put("F0301",comId);
        List<Map<String,Object>> list = countMapper.depActiveAnalysis(map);
        return Result.success(list, "查询成功");
    }

    @Override
    public Result highQualityUserActiveAnalysis(Map<String, Object> map, HttpServletRequest request) {
        LoginUser loginUser = tokenService.getLoginUser(request);
        Long userId = loginUser.getUserId();
        Long comId = t18Service.selectF0301ByF1801(userId);
        map.put("F0301",comId);
        List<Map<String,Object>> list = countMapper.highQualityUserActiveAnalysis(map);
        return Result.success(list, "查询成功");
    }
}
